<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<?php
	//启动session
	session_start();

	//表单数据的获取
	$strName=$_POST["userName"];
	$strPwd=$_POST["userPwd"];
	$strType=$_POST["userType"];
	$_SESSION['userName']=$strName;
/* ？ */	$_SESSION['userType']=trim($strType);

	//连接数据库
	$conn;
	include '../public/conn.php';
	
	if($strType=='1'){
	    $res=mysql_query("select * from student where sna='$strName' and spw='$strPwd'");
		
	    if($row = mysql_fetch_array($res)){
	    	echo("<script>");
			echo("window.location='../student/student.php';");
			echo("</script>");
		}
        else{
	        echo("<script>");
			echo("alert('登录信息有误，请重新输入！');");
			echo("window.location='sign.html#r';");
			echo("</script>");
		}
    }

	else if($strType=='0'){
		$res=mysql_query("select * from teacher where tna='$strName' and tpw='$strPwd'");

     if($row = mysql_fetch_array($res)){
    	echo("<script>");
		echo("window.location='../teacher/teacher.php';");
		echo("</script>");
	}
    else{
        echo("<script>");
		echo("alert('登录信息有误，请重新输入！');");
		echo("window.location='sign.html#r';");
		echo("</script>");
	}
	}

//关闭连接
	mysql_close();
?>